package example

import (
	"context"
	"grpc-server/global"
	pb "grpc-server/grpc-protocol/example"
)

type Greater struct {
	pb.UnimplementedGreeterServer
}

// NewGreaterServer 实例化server
func NewGreaterServer() pb.GreeterServer {
	return &Greater{}
}

// SayHello implements hello.GreeterServer
func (s *Greater) SayHello(ctx context.Context, req *pb.HelloRequest) (rep *pb.HelloReply, err error) {

	defer global.LOG.Info(req)

	rsp := pb.HelloReply{
		Message: "Hello " + req.GetName(),
		Code:    22,
	}

	return &rsp, nil
}
